<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->

<head>
    <meta charset="utf-8" />
    <title>添加配置项</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <link href="http://tv.speechb.com/lib/layui/css/layui.css" rel="stylesheet"/>
</head>
<body >
<!--
<script id="editor" type="text/plain" style="height: 150px;"/>

-->
<!-- Main content -->
<div style="margin-top: 30px;margin-right: 22px">
    <div class="layui-form" action="" style="max-width: 640px;margin: 0 auto">

        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input id="title" type="text" name="title" required  lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">展示排序</label>
            <div class="layui-input-inline">
                <input id="sort" name="sort" type="number" required lay-verify="required" placeholder="请输入序列号" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">用户展示界面排序（越小排序越靠前）</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">类选择型</label>
            <div class="layui-input-block">
                <select name="notice" lay-verify="required">
                    <option value="会员专享话术库">会员专享话术库</option>
                    <option value="普通话术库">普通话术库</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态选择</label>
            <div class="layui-input-block">
                <select name="status" lay-verify="required">
                    <option value="2">VIP</option>
                    <option value="1">可见</option>
                    <option value="0">隐藏</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item" style="text-align: center;">
            <div class="layui-input-block">
                <button id="submitBtn" class="layui-btn" lay-submit lay-filter="formDemo" style="margin: 0 auto">立即提交</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" charset="utf-8" src="http://tv.speechb.com/lib/layui/layui.js"></script>
<script src="http://tv.speechb.com/lib/superui/content/ui/global/jQuery/jquery.min.js"></script>
<script type="text/javascript">

    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            $("#submitBtn").attr("disabled","disabled")
            $.ajax({
                type : "POST",
                url : "/admin/speechcraft_title/title1-publish",
                data: {
                    "title": data.field.title,
                    "notice": data.field.notice,
                    "status":data.field.status,
                    "sort":data.field.sort
                },
                success : function(result) {
                    if(result.code==1) {
                        layer.msg('添加成功！', {icon: 1});
                        $("#title").val("");
                    } else {
                        layer.msg('生成失败了！', {icon: 5});
                    }
                    $("#submitBtn").removeAttr("disabled");
                },
                error : function(e){
                    layer.msg('请求异常！', {icon: 5});
                    $("#submitBtn").removeAttr("disabled");
                }
            });
            return false;
        });
    });
    $(function(){

        $("#copy_code").click(function () {
            var copyText = $("#activation_code");//获取对象
            copyText .select();//选择
            document.execCommand("Copy");//执行复制

            layer.msg('复制成功', {icon: 1});
        });
    });

</script>
</body>

</html>